home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / xlib06p1.zip / BACK.CPP next >
C/C++ Source or Header  |  1995-03-18  |  3KB  |  111 lines

  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <dos.h>
  4. #include <mem.h>
  5. #include "xlib.h"
  6. #include "xpoint.h"
  7. #include "xrect.h"
  8. #include "xpal.h"
  9. #include "xtext.h"
  10. #include "xline.h"
  11. #include "xcircle.h"
  12. #include "xmouse.h"
  13. #include "xpbitmap.h"
  14. #include "xscalebm.h"
  15. #include "xplanput.h"
  16. #include <time.h>
  17. #include <iostream.h>
  18.  
  19. BYTE XFont[ 2048 ];
  20. int loadfontX(char *fname)
  21. {
  22.     FILE *fp;
  23.  
  24.     fp = fopen(fname, "rb");
  25.  
  26.     if (fp == NULL) {
  27.         return 0;
  28.     } else {
  29.         fread(XFont, 8, 256, fp);
  30.         fclose(fp);
  31.         return 1;
  32.     }
  33. }
  34.  
  35. static BYTE  bm[] = {4,12,
  36.   /* plane 0 */
  37.   2,2,2,2,2,1,1,1,2,1,1,1,2,3,3,1,
  38.   2,0,0,3,2,0,0,3,2,0,0,3,2,0,0,3,
  39.   2,3,3,1,2,1,1,1,2,1,1,1,2,2,2,2,
  40.   /* plane 1 */
  41.   2,2,2,2,1,1,1,1,1,1,1,1,1,3,3,1,
  42.   1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,
  43.   1,3,3,1,1,1,1,1,1,1,1,1,2,2,2,2,
  44.   /* plane 2 */
  45.   2,2,2,2,1,1,1,1,1,1,1,1,1,3,3,1,
  46.   1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,
  47.   1,3,3,1,1,1,1,1,1,1,1,1,2,2,2,2,
  48.   /* plane 3 */
  49.   2,2,2,2,1,1,1,2,1,1,1,2,1,3,3,2,
  50.   3,0,0,2,3,0,0,2,3,0,0,2,3,0,0,2,
  51.   1,3,3,2,1,1,1,2,1,1,1,2,2,2,2,2};
  52.  
  53. BYTE StraightBm[] = {
  54.   5, 5,
  55.   2, 2, 2, 2, 2,
  56.   2, 1, 1, 1, 2, 
  57.   2, 1, 3, 1, 2, 
  58.   2, 1, 1, 1, 2, 
  59.   2, 2, 2, 2, 2
  60. };
  61.  
  62. BYTE bm2[ 2048 ];
  63.  
  64. const int CiNumTrials = 1000;
  65.  
  66. void main(
  67.   void
  68. )
  69. {
  70.   //a test of mode X routines in protected mode.  Just sets 320x240 mode.
  71.   x_set_mode( 2, (WORD)500 );
  72.   int iColor = 0;
  73.   x_text_init();
  74.   x_rect_fill( 0, 0, ScrnLogicalPixelWidth, ScrnLogicalHeight, VisiblePageOffs, 160 );
  75.   loadfontX( "fixed6x8.fnt" );
  76.   x_register_userfont( XFont );
  77.   x_set_font( 2 );
  78.   x_put_pbm( 161,100, VisiblePageOffs, bm );
  79.   x_put_masked_pbm( 110, 110, VisiblePageOffs, bm2 );
  80.  
  81.  
  82.   clock_t clkNormalBegin = 0;
  83.   clock_t clkNormalEnd = 0;
  84.   clkNormalBegin = clock();
  85.   for ( int iTrial = 0; iTrial < CiNumTrials; ++iTrial ) {
  86.     for (int iCounter = 0; iCounter < 180; ++iCounter ) {
  87.       x_put_masked_pbm( iCounter, iCounter, VisiblePageOffs, bm );
  88.     }
  89.   }
  90.   clkNormalEnd = clock();
  91.  
  92.   clock_t clkPlanarBegin = 0;
  93.   clock_t clkPlanarEnd = 0;
  94.   clkPlanarBegin = clock();
  95.   for ( iTrial = 0; iTrial < CiNumTrials; ++iTrial ) {
  96.     for ( int iPlaneLoop = 0; iPlaneLoop < 4; ++iPlaneLoop ) {
  97.       x_set_write_plane( (BYTE)iPlaneLoop );
  98.       for ( int iCounter = 0; iCounter < 180; ++iCounter ) {
  99.         x_put_plane_masked_pbm( iCounter, iCounter, VisiblePageOffs, bm );
  100.       }
  101.     }
  102.   }
  103.   clkPlanarEnd = clock();
  104.  
  105.   
  106.   x_text_mode();
  107.   cout << "Normal mode: " << ( clkNormalEnd - clkNormalBegin ) << "\n";
  108.   cout << "Planar mode: " << ( clkPlanarEnd - clkPlanarBegin ) << "\n";
  109.  
  110. }
  111.